from scipy.signal import butter, filtfilt

def butterworth_bandpass_filter(original_signal, order, low_cutoff, high_cutoff, sampling_frequency):
    """
    使用Butterworth滤波器实现带通滤波
    输入:
    original_signal - 原始信号
    order - 滤波器的阶数
    low_cutoff - 低频截止频率
    high_cutoff - 高频截止频率
    sampling_frequency - 采样频率
    """

    # 计算归一化的截止频率
    Wn = [2 * low_cutoff / sampling_frequency, 2 * high_cutoff / sampling_frequency]

    # 获取Butterworth滤波器的系数
    B_band, A_band = butter(order, Wn, btype='band')

    # 使用filtfilt进行零相位滤波
    bandpass_filtered_signal = filtfilt(B_band, A_band, original_signal)

    return bandpass_filtered_signal
